feat: add sha extend precompile. #1213
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Sha extend circuit
This PR adds sha extend precompile, computing the parameter
w[0..64]defined as follows:The sha extend circuit represents a single round computation in sha extend. It fetches the instruction at the same pc as the first cycle, reads the same register, and defines the global state with increasing cycles. I each instance, it reads w[i - 2], w[i - 7], w[i - 15], w[i - 16] from the memory and computes w[i] and writes it back.
Changes in
ceno_patchThe function is replaced from
syscall_sha256_extend(w_i: &mut [u32; 64]);tosyscall_sha256_extend(w_i: &mut u32):And the functionality in
ceno_emulis changed accordingly.Tiny change of
SelectTypeLayoutThe original definition is as follows:
while they are sometimes duplicated and in sha extend circuit, it needs to set
round_i = 16in the first round and updatepcduring the last round. Therefore, the definition is changed as follows: